# -*- coding: utf-8 -*-
# 项目配置相关文件
import os

baseDir = os.path.abspath(os.path.dirname(__file__))


class Config:
    """
    配置基类
    """
    APP_NAME = 'flasky'
    SECRET_KEY = 'SECRET-276-229-868'
    TEMPLATES_AUTO_RELOAD = True

    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1:33006/flasky?charset=utf8'
    SQLALCHEMY_POOL_SIZE = 2
    SQLALCHEMY_POOL_TIMEOUT = 30
    SQLALCHEMY_POOL_RECYCLE = -1

    # 追踪对象的修改并且发送信号
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    @staticmethod
    def init_app(app):
        pass


class DevelopmentConfig(Config):
    """
    开发环境配置
    """
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1:33006/flasky?charset=utf8'


class TestingConfig(Config):
    """
    测试环境配置
    """
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1:33006/flasky_test?charset=utf8'


class ProductionConfig(Config):
    """
    生产环境配置
    """
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:root@127.0.0.1:33006/flasky_prod?charset=utf8'


config = {
    'dev': DevelopmentConfig,
    'test': TestingConfig,
    'prod': ProductionConfig,
    'default': DevelopmentConfig,
}
